﻿using CoffeeShop.Models.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CoffeeShop.DAO
{
    public class RoleDao
    {
        private CFMSEntities _entities = new CFMSEntities();

        /// <summary>
        /// Get a Role by RoleId
        /// </summary>
        /// <param name="userName">roleId: RoleId input</param>
        /// <returns>Role</returns>
        public Role GetRoleById(int roleId)
        {
            try
            {
                Role roleResult = new Role();
                roleResult = (from role in _entities.Roles
                                  where role.RoleId == roleId
                                  select role).FirstOrDefault();
                return roleResult;
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                throw ex;
            }
        }
    }
}